//base64格式转file文件流


// dataurl ： base64 待格式      filename：文件名称

let base64toFile = (dataurl,filename='file') =>  {
    let arr = dataurl.split(',');
    let mime = arr[0].match(/:(.*?);/)[1];
    let suffix = mime.split('/')[1];
    let bstr = atob(arr[1]);//decodeURIComponent(escape(atob(arr[1])));//
    let n = bstr.length;
    let u8arr = new Uint8Array(n);
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }
    return new File([u8arr], `${filename}.dwg`, {
        type: mime
    });
}


export default base64toFile


